<?php
namespace Admin\Controller;
use Think\Controller;
class CountController extends CommonController {
    public function indexAction(){

       $this->display();
    }

    public function countajaxAction()
    {
    	$sql = "select count(id) cn,FROM_UNIXTIME(create_time,'%m-%d') days from question GROUP BY days ORDER BY days desc limit 7";
    	$res = M()->query($sql);

    	$tmp = array();

    	foreach ($res as $key => $value) {
    		$tmp[]=$value['cn'];
    	}

    	$sum = array_sum($tmp);

    	$res[]=array(
    		'cn'=>$sum,
    		'days'=>'总量',
    		);
    	
    	$res = array_reverse($res);

    	echo json_encode($res);
    }

}